package com.teng.smartdrawer;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.teng.smartdrawer.view.ProgressWebView;

public class TaobaoActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_taobao);

        ProgressWebView webView = (ProgressWebView) findViewById(R.id.progressWebView);

        WebSettings settings = webView.getSettings();
        webView.requestFocusFromTouch();
        webView.setWebChromeClient(new WebChromeClient());
        // 支持可以访问文件
        settings.setAllowFileAccess(true);
        // 设置此属性，可任意比例缩放
        settings.setLoadWithOverviewMode(true);
        // 支持缩放功能
        settings.setBuiltInZoomControls(true);
        // 支持JS
        settings.setJavaScriptEnabled(true);
        // 使网页自适应手机屏幕大小
        settings.setUseWideViewPort(true);
        settings.setSupportZoom(true);

        settings.setJavaScriptCanOpenWindowsAutomatically(true);
        settings.setCacheMode(WebSettings.LOAD_NO_CACHE);//不使用缓存
        settings.setDomStorageEnabled(true);
        // settings.setNeedInitialFocus(true);
        settings.setJavaScriptCanOpenWindowsAutomatically(true);

        webView.setWebViewClient(new WebViewClient() {
            public boolean shouldOverrideUrlLoading(WebView view, String url) { //  重写此方法表明点击网页里面的链接还是在当前的webview里跳转，不跳到浏览器那边
                view.loadUrl(url);
                return true;
            }
        });

        webView.loadUrl("https://tsksm.tmall.com/category-686497010.htm?spm=a1z10.1-b.w5002-13877831174.4.rcl32Y&search=y&catName=%B5%E7%D7%D3%C4%A3%BF%E9%B4%F3%C8%AB");

    }
}
